package cn.yunhe.service;

import cn.yunhe.dao.ChildTypeDao;
import cn.yunhe.entity.ChildType;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ChildTypeService {
    SqlSession session=SqlSessionFactoryUtil.getSqlSession();
    ChildTypeDao childTypeDao=session.getMapper(ChildTypeDao.class);

    public List<ChildType> findChildTypeByFatherId(int fid){
        return childTypeDao.findChildTypeByFatherId(fid);
    }

    public boolean addChildType(ChildType childType){
        boolean flag = childTypeDao.addChildType(childType);
        session.commit();
        session.close();
        return flag;
    }
   public   boolean deleteChildType(int cid){
       boolean flag = childTypeDao.deleteChildType(cid);
       session.commit();
       session.close();
       return flag;
   }

    public boolean updateChildType(String ctypename,int chtypeid){

        boolean flag =childTypeDao.updateChildType(ctypename,chtypeid);
        session.commit();
        session.close();
        return flag;
    }

    public List<ChildType>  findChildType(){
        return childTypeDao.findChildType();
    }
}
